home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / utility / pwg_key.zip / KRS100.ZIP / KRS.WCC < prev    next >
Text File  |  1995-05-18  |  4KB  |  123 lines

  1. '  Function KeyRegistration System (KRS)
  2. '  by Mark Schwandt & William Mantz
  3. '  for wcCODE programs.
  4. '
  5. '  This Code is hereby released to the Public Domain.
  6. '
  7. '  Usage:
  8. '
  9. '  INT  Registered = KRS(RegNumber as LONG, ProgId as Long)
  10. '
  11. '        returns FALSE (0) if RegNumber doesn't Match KRS calculation
  12. '        with supplied Program ID.   NOTE:  Program ID is what you
  13. '        pick when compiling your KeyMaker program.  It is an integer
  14. '        number from (1-99999).  Your Program MUST pass the
  15. '        RegNumber from your Program's CFG file, along with your
  16. '        Program ID number (hard coded) in your program.
  17. '
  18. '   Example:
  19. '
  20. '   Your Program reads a .CFG file and gets the Registration Number
  21. '   231909210 as variable RegNumber (that Sysop is using).
  22. '   You would then call the KRS() Function to determine if
  23. '   this number is correct.  You have picked 12300 as your Custom
  24. '   program ID number for this program. It can be any number from
  25. '   1 to 99999).  Here is the code....
  26. '
  27. '   DIM RegNumber as LONG
  28. '   DIM Registered as INTEGER
  29. '
  30. '   Registered = FALSE
  31. '
  32. '   OPEN cfgFile for INPUT AS #1
  33. '   INPUT #1, RegNumber
  34. '   CLOSE #1
  35. '
  36. '   IF KRS(RegNumber, 12300)  THEN
  37. '       REGISTERED = TRUE
  38. '   ELSE
  39. '       REGISTERED = FALSE
  40. '   END IF
  41. '
  42. '  The 12300 number in the KRS() function is the Number you picked
  43. '  as your Custom Program ID number.  It can be any number 1-99999).
  44. '
  45. '-----------------------------------------------------------------------
  46. '  Algorith Used:  (based on PRIME Number 7 and Your Custom ProgID)
  47. '  Wildcat! BBS Name is calculated into a CheckSum (All upper case).
  48. '  and added to the Wildcat! BBS Reg. ID Number CheckSum.
  49. '  The Combined CheckSum is then Multiplied to the Specific Custom
  50. '  Program ID number that the programmer uses for his Program.
  51. '  This total is then added to the Program ID number leaving a
  52. '  Resulted LONG Integer Number used for the Key.
  53. '  ChkSum(BBSName) + ChkSum(BBSRegNum) * 7 * ProgID + ProgID = Key as LONG
  54. '-----------------------------------------------------------------------
  55. '
  56. '  To use, Put '$ INCLUDE "KRS.WCC" in your Program at the Top which
  57. '          will include this function in the compilation.  The KRS.WCC
  58. '          MUST be located in the same directory when you compile.
  59. '
  60. '
  61. '
  62. 'DECLARE FUNCTION KRS(RegNumber AS LONG, ProgId as LONG) AS INTEGER
  63.  
  64. FUNCTION KRS( RegNumber as LONG, ProgId as LONG) AS Integer
  65. Dim Expand as Integer
  66. Dim StrChkSum as Long
  67. Dim ProgChkSum AS LONG
  68. Dim BBSName as STRING*30
  69. Dim BBSstrID as STRING*7
  70. DIM BBSId as LONG
  71.  
  72. '  first, Get the BBS Name from MakeWild's Record information.
  73. '  Trim it and make it all UPPER CASE, then Get the CheckSum of it.
  74.  
  75. BBSName = UCASE(MakeWild.BBSname)
  76. BBSName = TRIM(BBSName)
  77. StrChkSum = 0
  78. For Expand = 1 to Len(BBSName)
  79.         StrChkSum = StrChkSum + Asc(Mid(BBSName,Expand,1))
  80. Next Expand
  81.  
  82. '  StrChkSum has the CheckSum of the BBS name.
  83.  
  84. '  Next, Get the BBS Reg Number from MakeWild's record Information.
  85. '  and Get the ChkSum of it.... ProgChkSum contains the iD.
  86.  
  87. BBSstrID = UCASE(MakeWild.RegString)
  88. BBSstrID = TRIM(BBSstrID)
  89. ProgChkSum = 0
  90. For Expand = 1 to Len(BBSstrID)
  91.         ProgChkSum = ProgChkSum + Asc(Mid(BBSstrID,Expand,1))
  92. Next Expand
  93.  
  94. '  Add the BBSName CheckSum and the BBS ID checkSum together.
  95.  
  96. ProgChkSum = ProgChkSum + StrChkSum
  97.  
  98. '  Multiply the CheckSum by the Prime Number 7
  99.  
  100. ProgChkSum = ProgChkSum * 7
  101.  
  102. ' Multiply the ProgChkSum  by the Program's custom ID number.
  103.  
  104. ProgChkSum = ProgChkSum * ProgId
  105.  
  106. ' Add the Calculated CheckSum by Program's Custom ID Number.
  107.  
  108. ProgChkSum = ProgChkSum + ProgId
  109.  
  110. ' -------------------------------------------------------------
  111. '  Calculations are complete!  Now do the compare with
  112. '  what was inputed to the function.
  113. '
  114. IF ProgChkSum = RegNumber THEN
  115.         KRS = -1
  116. ELSE
  117.         KRS = 0
  118. END IF
  119.  
  120. END FUNCTION
  121.  
  122.  
  123.